<div class="layuimini-container layuimini-page-anim">
    <div class="layuimini-main">

        <div class="layui-form layuimini-form">
            <div class="layui-form-item">
                <label class="layui-form-label">登录用户名</label>
                <div class="layui-input-block">
                    <input disabled type="text" name="username" class="layui-input layui-disabled">
                    <tip>账号创建后，登录用户名不允许修改</tip>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">头像</label>
                <div class="layui-input-block">
                    <input type="text" name="avatar" maxlength="255" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">昵称</label>
                <div class="layui-input-block">
                    <input type="text" name="nickname" maxlength="20" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">手机</label>
                <div class="layui-input-block">
                    <input type="text" name="mobile" maxlength="20" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-block">
                    <input type="text" name="email" maxlength="20" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="saveBtn">确认修改</button>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use([], function () {
        var $ = layui.jquery,
            layer = layui.layer,
            http = layui.http,
            form = layui.form,
            miniPage = layui.miniPage;

        //拉取信息
        http.ajaxPost('/admin/Admin/getInfo', {}, function (data) {
            $("[name='username']").val(data.username);
            $("[name='avatar']").val(data.avatar);
            $("[name='nickname']").val(data.nickname);
            $("[name='mobile']").val(data.mobile);
            $("[name='email']").val(data.email);
        });

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            http.ajaxPost('/admin/Admin/saveInfo', data.field, function (data) {
                layer.msg('修改成功', { time: 1000 }, function () {
                    location.reload();
                });
            });
        });

    });
</script>